home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Bin / DXUtils / Visual Studio 6.0 Wizards / Source Code / Template / d3dfont.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-12  |  2.5 KB  |  78 lines

  1. //-----------------------------------------------------------------------------
  2. // File: D3DFont.h
  3. //
  4. // Desc: Texture-based font class
  5. //-----------------------------------------------------------------------------
  6. #ifndef D3DFONT_H
  7. #define D3DFONT_H
  8. #include <tchar.h>
  9. #include <D3D9.h>
  10.  
  11.  
  12. // Font creation flags
  13. #define D3DFONT_BOLD        0x0001
  14. #define D3DFONT_ITALIC      0x0002
  15. #define D3DFONT_ZENABLE     0x0004
  16.  
  17. // Font rendering flags
  18. #define D3DFONT_CENTERED_X  0x0001
  19. #define D3DFONT_CENTERED_Y  0x0002
  20. #define D3DFONT_TWOSIDED    0x0004
  21. #define D3DFONT_FILTERED    0x0008
  22.  
  23.  
  24.  
  25.  
  26. //-----------------------------------------------------------------------------
  27. // Name: class CD3DFont
  28. // Desc: Texture-based font class for doing text in a 3D scene.
  29. //-----------------------------------------------------------------------------
  30. class CD3DFont
  31. {
  32.     TCHAR   m_strFontName[80];            // Font properties
  33.     DWORD   m_dwFontHeight;
  34.     DWORD   m_dwFontFlags;
  35.  
  36.     LPDIRECT3DDEVICE9       m_pd3dDevice; // A D3DDevice used for rendering
  37.     LPDIRECT3DTEXTURE9      m_pTexture;   // The d3d texture for this font
  38.     LPDIRECT3DVERTEXBUFFER9 m_pVB;        // VertexBuffer for rendering text
  39.     DWORD   m_dwTexWidth;                 // Texture dimensions
  40.     DWORD   m_dwTexHeight;
  41.     FLOAT   m_fTextScale;
  42.     FLOAT   m_fTexCoords[128-32][4];
  43.     DWORD   m_dwSpacing;                  // Character pixel spacing per side
  44.  
  45.     // Stateblocks for setting and restoring render states
  46.     LPDIRECT3DSTATEBLOCK9 m_pStateBlockSaved;
  47.     LPDIRECT3DSTATEBLOCK9 m_pStateBlockDrawText;
  48.  
  49. public:
  50.     // 2D and 3D text drawing functions
  51.     HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor, 
  52.                       const TCHAR* strText, DWORD dwFlags=0L );
  53.     HRESULT DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, 
  54.                             FLOAT fXScale, FLOAT fYScale, DWORD dwColor, 
  55.                             const TCHAR* strText, DWORD dwFlags=0L );
  56.     HRESULT Render3DText( const TCHAR* strText, DWORD dwFlags=0L );
  57.     
  58.     // Function to get extent of text
  59.     HRESULT GetTextExtent( const TCHAR* strText, SIZE* pSize );
  60.  
  61.     // Initializing and destroying device-dependent objects
  62.     HRESULT InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice );
  63.     HRESULT RestoreDeviceObjects();
  64.     HRESULT InvalidateDeviceObjects();
  65.     HRESULT DeleteDeviceObjects();
  66.  
  67.     // Constructor / destructor
  68.     CD3DFont( const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
  69.     ~CD3DFont();
  70. };
  71.  
  72.  
  73.  
  74.  
  75. #endif
  76.  
  77.  
  78.